import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [{
		path: '/login',
		component: () => import('@/views/login/index'),
		hidden: true
	},

	{
		path: '/404',
		component: () => import('@/views/404'),
		hidden: true
	},
	{
		path: '/',
		component: Layout,
		redirect: '/dashboard',
		children: [{
			path: 'dashboard',
			name: 'Dashboard',
			component: () => import('@/views/dashboard/index'),
			meta: {
				title: '首页',
				icon: 'dashboard'
			}
		}]
	}
]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [

	{
		path: '/user',
		component: Layout,
		meta: {
			title: '系统用户管理',
			icon: 'link'
		},
		children: [{
				path: 'index',
				component: () => import('@/views/user/index'),
				meta: {
					title: '系统用户管理'
				}
			},
			{
				path: 'add',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/user/add'),
				meta: {
					title: '系统用户管理',
					activeMenu: '/user/index'
				}
			},
			{
				path: 'see',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/user/see'),
				meta: {
					title: '系统用户管理',
					activeMenu: '/user/index'
				}
			}
		]
	},
	{
		path: '/member',
		component: Layout,
		meta: {
			title: '会员管理',
			icon: 'link'
		},
		children: [{
				path: 'index',
				component: () => import('@/views/member/index'),
				meta: {
					title: '会员管理'
				}
			},
			{
				path: 'add',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/member/add'),
				meta: {
					title: '会员管理',
					activeMenu: '/member/index'
				}
			},
			{
				path: 'see',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/member/see'),
				meta: {
					title: '会员管理',
					activeMenu: '/member/index'
				}
			},
			{
				path: 'dsee',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/member/dsee'),
				meta: {
					title: '会员管理',
					activeMenu: '/member/index'
				}
			}
		]
	},
	{
		path: '/screen',
		component: Layout,
		meta: {
			title: '筛选管理',
			icon: 'link'
		},
		children: [{
				path: '/screen/newhouse/index',
				component: () => import('@/views/screen/newhouse/index'),
				meta: {
					title: '新房'
				}
			},{
				path: '/screen/newhouse/priceadd', 
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/screen/newhouse/priceadd'),
				meta: {
					title: '新房',
					activeMenu: '/screen/newhouse/index'
				}
			},{
				path: '/screen/newhouse/moreadd', 
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/screen/newhouse/moreadd'),
				meta: {
					title: '新房',
					activeMenu: '/screen/newhouse/index'
				}
			},{
				path: '/screen/renting/priceadd', 
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/screen/renting/priceadd'),
				meta: {
					title: '租房',
					activeMenu: '/screen/renting/index'
				}
			},{
				path: '/screen/renting/moreadd', 
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/screen/renting/moreadd'),
				meta: {
					title: '租房',
					activeMenu: '/screen/renting/index'
				}
			},{
				path: '/screen/second/priceadd', 
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/screen/second/priceadd'),
				meta: {
					title: '二手房',
					activeMenu: '/screen/second/index'
				}
			},{
				path: '/screen/second/moreadd', 
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/screen/second/moreadd'),
				meta: {
					title: '二手房',
					activeMenu: '/screen/second/index'
				}
			},{
				path: '/screen/quarters/priceadd', 
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/screen/quarters/priceadd'),
				meta: {
					title: '小区',
					activeMenu: '/screen/quarters/index'
				}
			},{
				path: '/screen/quarters/moreadd', 
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/screen/quarters/moreadd'),
				meta: {
					title: '小区',
					activeMenu: '/screen/quarters/index'
				}
			},
			{
					path: '/screen/quarters/index',
					component: () => import('@/views/screen/quarters/index'),
					meta: {
						title: '小区'
					}
				},
			{
					path: '/screen/renting/index',
					component: () => import('@/views/screen/renting/index'),
					meta: {
						title: '租房'
					}
				},
			{
					path: '/screen/second/index',
					component: () => import('@/views/screen/second/index'),
					meta: {
						title: '二手房'
					}
				}
			
		]
	},
	{
		path: '/adManage',
		component: Layout,
		meta: {
			title: '广告管理',
			icon: 'link'
		},
		children: [{
				path: 'index',
				component: () => import('@/views/adManage/index'),
				meta: {
					title: '广告管理'
				}
			},
			{
				path: 'add',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/adManage/add'),
				meta: {
					title: '广告管理',
					activeMenu: '/adManage/index'
				}
			},
			{
				path: 'see',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/adManage/see'),
				meta: {
					title: '广告管理',
					activeMenu: '/adManage/index'
				}
			}
		]
	},
	// {
	// 	path: '/kitManage',
	// 	component: Layout,
	// 	meta: {
	// 		title: '套餐管理',
	// 		icon: 'link'
	// 	},
	// 	children: [{
	// 			path: 'index',
	// 			component: () => import('@/views/kitManage/index'),
	// 			meta: {
	// 				title: '套餐管理'
	// 			}
	// 		},
	// 		{
	// 			path: 'setIndex',
	// 			hidden: true, // 不在侧边栏线上
	// 			component: () => import('@/views/kitManage/setindex'),
	// 			meta: {
	// 				title: '套餐管理',
	// 				activeMenu: '/kitManage/index'
	// 			}
	// 		},
	// 		{
	// 			path: 'setAdd',
	// 			hidden: true, // 不在侧边栏线上
	// 			component: () => import('@/views/kitManage/setadd'),
	// 			meta: {
	// 				title: '套餐管理',
	// 				activeMenu: '/kitManage/index'
	// 			}
	// 		},
	// 		{
	// 			path: 'add',
	// 			hidden: true, // 不在侧边栏线上
	// 			component: () => import('@/views/kitManage/add'),
	// 			meta: {
	// 				title: '套餐管理',
	// 				activeMenu: '/kitManage/index'
	// 			}
	// 		},
	// 		{
	// 			path: 'setSee',
	// 			hidden: true, // 不在侧边栏线上
	// 			component: () => import('@/views/kitManage/setSee'),
	// 			meta: {
	// 				title: '套餐管理',
	// 				activeMenu: '/kitManage/index'
	// 			}
	// 		},
	// 		{
	// 			path: 'see',
	// 			hidden: true, // 不在侧边栏线上
	// 			component: () => import('@/views/kitManage/see'),
	// 			meta: {
	// 				title: '套餐管理',
	// 				activeMenu: '/kitManage/index'
	// 			}
	// 		}
	// 	]
	// },
	{
		path: '/setMeal',
		component: Layout,
		meta: {
			title: '套餐修改',
			icon: 'link'
		},
		children: [{
				path: 'index',
				component: () => import('@/views/setMeal/index'),
				meta: {
					title: '套餐修改'
				}
			}
		]
	},
	{
		path: '/cityManage',
		component: Layout,
		meta: {
			title: '城市管理',
			icon: 'link'
		},
		children: [{
				path: 'index',
				component: () => import('@/views/cityManage/index'),
				meta: {
					title: '城市管理'
				}
			},
			{
				path: 'add',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/cityManage/add'),
				meta: {
					title: '城市管理',
					activeMenu: '/cityManage/index'
				}
			},
			{
				path: 'see',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/cityManage/see'),
				meta: {
					title: '城市管理',
					activeMenu: '/cityManage/index'
				}
			}
		]
	},
	{
		path: '/areaManage',
		component: Layout,
		meta: {
			title: '地区管理',
			icon: 'link'
		},
		children: [{
				path: 'index',
				component: () => import('@/views/areaManage/index'),
				meta: {
					title: '地区管理'
				}
			},
			{
				path: 'add',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/areaManage/add'),
				meta: {
					title: '地区管理',
					activeMenu: '/areaManage/index'
				}
			}
		]
	},
	{
		path: '/smsManage',
		component: Layout,
		meta: {
			title: '短信模板',
			icon: 'link'
		},
		children: [{
				path: 'index',
				component: () => import('@/views/smsManage/index'),
				meta: {
					title: '短信模板'
				}
			},
			{
				path: 'add',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/smsManage/add'),
				meta: {
					title: '短信模板',
					activeMenu: '/smsManage/index'
				}
			},
			{
				path: 'see',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/smsManage/see'),
				meta: {
					title: '短信模板',
					activeMenu: '/smsManage/index'
				}
			}
		]
	},
	{
		path: '/shopManage',
		component: Layout,
		meta: {
			title: '门店管理',
			icon: 'link'
		},
		children: [{
				path: 'index',
				component: () => import('@/views/shopManage/index'),
				meta: {
					title: '门店管理'
				}
			},
			{
				path: 'add',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/shopManage/add'),
				meta: {
					title: '门店管理',
					activeMenu: '/shopManage/index'
				}
			},
			{
				path: 'see',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/shopManage/see'),
				meta: {
					title: '门店管理',
					activeMenu: '/shopManage/index'
				}
			}
		]
	},
	{
		path: '/residentialManage',
		component: Layout,
		meta: {
			title: '小区管理',
			icon: 'link'
		},
		children: [{
				path: 'index',
				component: () => import('@/views/residentialManage/index'),
				meta: {
					title: '小区管理'
				}
			},
			{
				path: 'add',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/residentialManage/add'),
				meta: {
					title: '小区管理',
					activeMenu: '/residentialManage/index'
				}
			},
			{
				path: 'see',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/residentialManage/see'),
				meta: {
					title: '小区管理',
					activeMenu: '/residentialManage/index'
				}
			}
		]
	},
	{
		path: '/sellManage',
		component: Layout,
		meta: {
			title: '售房管理',
			icon: 'link'
		},
		children: [{
				path: 'index',
				component: () => import('@/views/sellManage/index'),
				meta: {
					title: '售房管理'
				}
			},
			{
				path: 'add',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/sellManage/add'),
				meta: {
					title: '售房管理',
					activeMenu: '/sellManage/index'
				}
			},
			{
				path: 'see',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/sellManage/see'),
				meta: {
					title: '售房管理',
					activeMenu: '/sellManage/index'
				}
			}
		]
	},
	{
		path: '/rentManage',
		component: Layout,
		meta: {
			title: '租房管理',
			icon: 'link'
		},
		children: [{
				path: 'index',
				component: () => import('@/views/rentManage/index'),
				meta: {
					title: '租房管理'
				}
			},
			{
				path: 'add',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/rentManage/add'),
				meta: {
					title: '租房管理',
					activeMenu: '/rentManage/index'
				}
			},
			{
				path: 'see',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/rentManage/see'),
				meta: {
					title: '租房管理',
					activeMenu: '/rentManage/index'
				}
			}
		]
	},
	{
		path: '/buildManage',
		component: Layout,
		meta: {
			title: '楼盘管理',
			icon: 'link'
		},
		children: [{
				path: 'index',
				component: () => import('@/views/buildManage/index'),
				meta: {
					title: '楼盘管理',
					activeMenu: '/buildManage/index'
				}
			},
			{
				path: 'permitIndex',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/buildManage/permitIndex'),
				meta: {
					title: '预售证管理',
					activeMenu: '/buildManage/index'
				}
			},
			{
				path: 'permitAdd',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/buildManage/permitAdd'),
				meta: {
					title: '预售证管理',
					activeMenu: '/buildManage/index'
				}
			},
			{
				path: 'priceIndex',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/buildManage/priceIndex'),
				meta: {
					title: '均价走势',
					activeMenu: '/buildManage/index'
				}
			},
			{
				path: 'priceAdd',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/buildManage/priceAdd'),
				meta: {
					title: '均价走势',
					activeMenu: '/buildManage/index'
				}
			},
			{
				path: 'add',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/buildManage/add'),
				meta: {
					title: '楼盘管理',
					activeMenu: '/buildManage/index'
				}
			},
			{
				path: 'see',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/buildManage/see'),
				meta: {
					title: '楼盘管理',
					activeMenu: '/buildManage/index'
				}
			}
		]
	},
	{
		path: '/apartmentManage',
		component: Layout,
		meta: {
			title: '户型管理',
			icon: 'link'
		},
		children: [{
				path: 'index',
				component: () => import('@/views/apartmentManage/index'),
				meta: {
					title: '户型管理'
				}
			},
			{
				path: 'add',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/apartmentManage/add'),
				meta: {
					title: '户型管理',
					activeMenu: '/apartmentManage/index'
				}
			},
			{
				path: 'see',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/apartmentManage/see'),
				meta: {
					title: '户型管理',
					activeMenu: '/apartmentManage/index'
				}
			}
		]
	},
	{
		path: '/categoryManage',
		component: Layout,
		meta: {
			title: '类型管理',
			icon: 'link'
		},
		children: [{
				path: 'index',
				component: () => import('@/views/categoryManage/index'),
				meta: {
					title: '类型管理'
				}
			},
			{
				path: 'add',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/categoryManage/add'),
				meta: {
					title: '类型管理',
					activeMenu: '/categoryManage/index'
				}
			},
			{
				path: 'sonIndex',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/categoryManage/sonIndex'),
				meta: {
					title: '类型管理',
					activeMenu: '/categoryManage/index'
				}
			},
			{
				path: 'sonAdd',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/categoryManage/sonAdd'),
				meta: {
					title: '类型管理',
					activeMenu: '/categoryManage/index'
				}
			}
		]
	},{
		path: '/freedesign',
		component: Layout,
		meta: {
			title: '免费设计',
			icon: 'link'
		},
		children: [{
				path: 'index',
				component: () => import('@/views/freedesign/index'),
				meta: {
					title: '免费设计'
				}
			}
		]
	},{
		path: '/configure',
		component: Layout,
		meta: {
			title: '后台配置',
			icon: 'link'
		},
		children: [{
				path: 'index',
				component: () => import('@/views/configure/index'),
				meta: {
					title: '后台配置'
				}
			},{
				path: 'add',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/configure/add'),
				meta: {
					title: '后台配置'
				}
			}
		]
	},{
		path: '/notice',
		component: Layout,
		meta: {
			title: '后台推送',
			icon: 'link'
		},
		children: [{
				path: 'index',
				component: () => import('@/views/notice/index'),
				meta: {
					title: '后台推送'
				}
			},{
				path: 'add',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/notice/add'),
				meta: {
					title: '后台推送'
				}
			}
		]
	},
	{
		path: '/examine',
		component: Layout,
		meta: {
			title: '审核管理',
			icon: 'link'
		},
		children: [{
			path: 'index',
			component: () => import('@/views/examine/index'),
			meta: {
				title: '审核管理'
			}
		}, {
			path: 'see',
			hidden: true, // 不在侧边栏线上
			component: () => import('@/views/examine/see'),
			meta: {
				title: '审核管理',
				activeMenu: '/views/examine/index'
			}
		}, {
			path: 'seea',
			hidden: true, // 不在侧边栏线上
			component: () => import('@/views/examine/seea'),
			meta: {
				title: '审核管理',
				activeMenu: '/views/examine/index'
			}
		}, {
			path: 'renovationAdd',
			hidden: true, // 不在侧边栏线上
			component: () => import('@/views/examine/renovationAdd'),
			meta: {
				title: '建材公司',
				activeMenu: '/views/examine/index'
			}
		},{
			path: 'decorationAdd',
			hidden: true, // 不在侧边栏线上
			component: () => import('@/views/examine/decorationAdd'),
			meta: {
				title: '装修公司',
				activeMenu: '/views/examine/index'
			}
		}, {
			path: 'materialsStoreAdd',
			hidden: true, // 不在侧边栏线上
			component: () => import('@/views/examine/materialsStoreAdd'),
			meta: {
				title: '建材门店',
				activeMenu: '/views/examine/index'
			}
		}
		]
	},{
		path: '/works',
		component: Layout,
		meta: {
			title: '作品管理',
			icon: 'link'
		},
		children: [{
			path: 'index',
			component: () => import('@/views/works/index'),
			meta: {
				title: '作品管理'
			}
		},
			{
				path: 'see',
				hidden: true, // 不在侧边栏线上
				component: () => import('@/views/works/see'),
				meta: {
					title: '作品管理',
					activeMenu: '/views/works/index'
				}
			},
		]
	},
	// 404 page must be placed at the end !!!
	{
		path: '*',
		redirect: '/404',
		hidden: true
	},
	{
		path: '/journal',
		component: Layout,
		meta: {
			title: '系统日志',
			icon: 'link'
		},
		children: [{
			path: 'index',
			component: () => import('@/views/journal/index'),
			meta: {
				title: '系统日志'
			}
		}]
	},
	{
		path: '/report',
		component: Layout,
		meta: {
			title: '举报管理',
			icon: 'link'
		},
		children: [{
			path: 'index',
			component: () => import('@/views/report/index'),
			meta: {
				title: '举报管理'
			}
		}]
	},
	{
		path: '/appointment',
		component: Layout,
		meta: {
			title: '预约管理',
			icon: 'link'
		},
		children: [{
			path: 'index',
			component: () => import('@/views/appointment/index'),
			meta: {
				title: '预约管理'
			}
		}]
	},
	{
		path: '/feedback',
		component: Layout,
		meta: {
			title: '问题反馈列表',
			icon: 'link'
		},
		children: [{
			path: 'index',
			component: () => import('@/views/feedback/index'),
			meta: {
				title: '问题反馈列表'
			}
		}]
	},
	{
		path: '/roommate',
		component: Layout,
		meta: {
			title: '找室友管理',
			icon: 'link'
		},
		children: [{
			path: 'index',
			component: () => import('@/views/roommate/index'),
			meta: {
				title: '找室友管理'
			}
		},
		 {
			path: 'see',
			hidden: true, // 不在侧边栏线上
			component: () => import('@/views/roommate/see'),
			meta: {
				title: '找室友管理',
				activeMenu: '/views/examine/index'
			}
		}
		]
	},
	{
		path: '/Information',
		component: Layout,
		meta: {
			title: '资讯管理',
			icon: 'link'
		},
		children: [{
			path: 'index',
			component: () => import('@/views/Information/index'),
			meta: {
				title: '资讯管理'
			}
		},{
			path: 'agentAdd',
			hidden: true, // 不在侧边栏线上
			component: () => import('@/views/Information/agentAdd'),
			meta: {
				title: '资讯管理'
			}
		},{
			path: 'see',
			hidden: true, // 不在侧边栏线上
			component: () => import('@/views/Information/see'),
			meta: {
				title: '资讯管理'
			}
		},
		]
	},
	// {
	// 	path: '/shops',
	// 	component: Layout,
	// 	meta: {
	// 		title: '商品写字楼管理',
	// 		icon: 'link'
	// 	},
	// 	children: [{
	// 		path: 'index',
	// 		component: () => import('@/views/shops/index'),
	// 		meta: {
	// 			title: '商品写字楼管理'
	// 		}
	// 	},{
	// 		path: 'agentAdd',
	// 		hidden: true, // 不在侧边栏线上
	// 		component: () => import('@/views/shops/agentAdd'),
	// 		meta: {
	// 			title: '商品写字楼管理'
	// 		}
	// 	},{
	// 		path: 'see',
	// 		hidden: true, // 不在侧边栏线上
	// 		component: () => import('@/views/shops/see'),
	// 		meta: {
	// 			title: '商品写字楼管理'
	// 		}
	// 	},
	// 	]
	// },
	{
		path: '/dynamic',
		component: Layout,
		meta: {
			title: '楼盘动态',
			icon: 'link'
		},
		children: [{
			path: '/index',
			component: () => import('@/views/dynamic/index'),
			meta: {
				title: '楼盘动态'
			}
		},{
			path: '/dynamic/see',
			hidden: true, // 不在侧边栏线上
			component: () => import('@/views/dynamic/see'),
			meta: {
				title: '楼盘动态'
			}
		}
		]
	}


]

const createRouter = () => new Router({
	// mode: 'history', // require service support
	scrollBehavior: () => ({
		y: 0
	}),
	routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
	const newRouter = createRouter()
	router.matcher = newRouter.matcher // reset router
}

export default router
